package com.hzqy.service.statistics;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.hzqy.persistence.dao.statistics.ListenDao;
import com.hzqy.persistence.dao.statistics.OrderSourceDao;
import com.hzqy.service.core.GenericServiceBean;
import com.hzqy.web.vo.PmsUserVo;
import com.hzqy.web.vo.StatDataListenAllVo;
import com.hzqy.web.vo.StatDataListenTop20Vo;
import com.hzqy.web.vo.StatDataListenVo;
import com.hzqy.web.vo.StatDataOrderSourceVo;

@Service
public class OrderSourceServiceBean extends GenericServiceBean<PmsUserVo, OrderSourceDao, Integer>{
	private static final long serialVersionUID = 1L;
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	
	@Resource
	private OrderSourceDao orderSourceDao;
	
	@Override
	public OrderSourceDao getEntityDao() {
		return orderSourceDao;
	}
	

	public Map<String, Object> selectOrderSourceList(StatDataOrderSourceVo dataOrderSourceVo, int curPage, int pageSize) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = orderSourceDao.selectOrderSourceCount(dataOrderSourceVo);
		map.put("total", rowCount);
		if(rowCount > 0 && curPage > 0 && pageSize > 0) {
			map.put("firstResult", (curPage-1)*pageSize);
			map.put("maxResults", pageSize);
			map.put("f_sdos_type", dataOrderSourceVo.getF_sdos_type());
			map.put("f_sdos_resolution", dataOrderSourceVo.getF_sdos_resolution());
			map.put("f_sdos_productid", dataOrderSourceVo.getF_sdos_productid());
			map.put("beginDate", dataOrderSourceVo.getBeginDate());
			map.put("endDate", dataOrderSourceVo.getEndDate());
			map.put("monthDate", dataOrderSourceVo.getMonthDate());
			map.put("weekDate", dataOrderSourceVo.getWeekDate());
			List<StatDataOrderSourceVo> results = orderSourceDao.selectOrderSourceList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<StatDataOrderSourceVo>());
		}
		return map;
	}
	
	public Map<String,Object> selectExcelList(StatDataOrderSourceVo dataOrderSourceVo) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = orderSourceDao.selectOrderSourceCount(dataOrderSourceVo);
		map.put("total", rowCount);
		if(rowCount > 0) {
			map.put("f_sdos_type", dataOrderSourceVo.getF_sdos_type());
			map.put("f_sdos_resolution", dataOrderSourceVo.getF_sdos_resolution());
			map.put("f_sdos_productid", dataOrderSourceVo.getF_sdos_productid());
			map.put("beginDate", dataOrderSourceVo.getBeginDate());
			map.put("endDate", dataOrderSourceVo.getEndDate());
			map.put("monthDate", dataOrderSourceVo.getMonthDate());
			map.put("weekDate", dataOrderSourceVo.getWeekDate());
			List<StatDataOrderSourceVo> results = orderSourceDao.selectOrderSourceExcelList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<StatDataOrderSourceVo>());
		}
		return map;
	}
	
}
